package com.qiaoanju.commons.vo;

import com.qiaoanju.commons.constants.ErrorCodes;

/**
 * Created by eversec
 * on 2017/10/21.
 */
public class ResultVo<T>{

    public static final ResultVo<String> SYSTEM_ERROR = new ResultVo<String>(false, ErrorCodes.SYSTEM_ERROR);

    public static final ResultVo<String> PARAM_NULL = new ResultVo<String>(false, ErrorCodes.PARAM_NULL);

    private boolean result;

    private String msg;

    private short errorCode;

    private T data;

    public ResultVo(boolean result){
        short errorCode = -1;
        if(result){
            errorCode = ErrorCodes.NO_ERROR;
        }
        this.result = result;
        this.errorCode = errorCode;
        this.msg = "";
    }

    public ResultVo(boolean result,short errorCode){
        this(result,errorCode,"");
    }

    public ResultVo(boolean result,short errorCode,String msg){
        this.result = result;
        this.errorCode = errorCode;
        this.msg = msg;
    }

    public boolean isResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public short getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(short errorCode) {
        this.errorCode = errorCode;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

}
